clear all
set more off
cd "/Users/yasenov/Dropbox (IPL)/RefugeeBan/Data"

use "WRAPS/wraps.dta"

isid year state city origin

**********
**********
**********
* BY YEAR (1) - AGGREGATE 
preserve
collapse (sum) refugees, by(year)
sum
twoway (line refugees year), ///
	subtitle("Panel A: Nationwide", size(med)) xtitle("Year", size(med)) ///
	ytitle(" ") ///
	xline(2016) ///
	ytitle("New Refugee Arrivals", size(med)) ///
	ylabel(0(20000)100000) ///
	legend(off) ///
	name(gr1_a, replace)
restore

**********
**********
**********
* BY YEAR (2) - HIGH/MED/LOW RECEIVING COUNTRIES 
preserve
collapse (sum) refugees, by(year fips)
tempfile file1
save `file1'

******* GET TREATMENT GROUP INDICATORS *******
collapse (sum) refugees if year <= 2016, by(fips)
xtile group = refugees, n(3)
tab group, m

keep fips group
tempfile edno
save `edno'
*******

use `file1', clear
merge m:1 fips using `edno', nogen
	
collapse (sum) refugees, by(year group)
reshape wide refugees, i(year) j(group)
sum
list

twoway (line refugees1 year,  lpattern(shortdash)) ///
	(line refugees2 year, lcolor(red) lpattern(longdash)), ///
	legend(off) ///
	yscale(range(0 810)) ///
	ylabel(0 "0" 200 "200" 400 "400" 600 "600" 800 "800" 801 "            ", notick  labsize(medium)) ///	
	xline(2016) ///
	xlabel(2000(5)2020,  labsize(medium)) ///
	xtitle("Year", size(medlarge)) ytitle("") ///
	name(gr1_b, replace)	
	
twoway (line refugees3 year, lcolor(green) lpattern(solid)), ///
	legend(off) ///
	xline(2016) ///
	ylabel(20000(20000)100000, notick labsize(medium)) ///
	xtitle("") ytitle("") ///
	title("Panel B: Top/Middle/Bottom Tercile Counties", size(large)) ///
	xscale(off) ///
	name(gr1_c, replace)		
	
graph combine gr1_c gr1_b, rows(2) imargin(vsmall) name(gr1_bc)

graph combine gr1_a gr1_bc, rows(1)

graph export "../results/fig_research_design.pdf", replace
